package VWorldGameStudio.events;

import VWorldGameStudio.FCEvent;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Random;

public class CaseEvent extends FCEvent implements Serializable {

    // 箱子
    @Setter
    @Getter
    private long casemoney = 0;
    // 物品ID
    @Setter
    @Getter
    public String[] caseitem = new String[4];

    public CaseEvent(String type, String name) {
        super(type, name);
    }

    public void setCaseMoney() {
        this.casemoney = 0;
    }

    public void deleteCaseItemOfNum(int num) {
        this.caseitem[num] = "null";
    }

    public boolean isCaseNull() {
        int i = 0;
        for (String o : caseitem) {
            if (o != null && o.indexOf("null") < 0)
                i++;
        }
        if (i > 0) {
            return false;
        }
        return true;
    }


    public long getCaseMoney() {
        if (casemoney > 0) {
            return (int) (new Random().nextInt((int) (casemoney / 3)) + this.casemoney / 0.8);
        } else {
            return 0;
        }
    }

}
